/**
 * Created by sens on 2020/5/2.
 */
/**
 * Created by sens on 2020/5/2.
 */
(function () {
    typeof window.sens !== 'object' && (window.sens = {});
})(window);

Object.assign(window.sens, (function () {
    function log(msg, is1P) {
        let logPanel = document.getElementById('log-panel');
        let textDom = document.createElement('p');
        textDom.innerHTML = (is1P ? '<span style="font-size: 24px; color: darkolivegreen">攻：</span>' : '<span style="font-size: 24px; color: #9c5200">防：</span>') + logConvert(msg, is1P);
        logPanel.appendChild(textDom);
        logPanel.scrollTop = 9999;
    }

    function logConvert(text, is1P) {
        return text.replace(/\[(.+?)\]/gim, function (match, $0) {
            return `<strong>` + $0 + '</strong>'
        }).replace(/\【(.+?)\】/gim, function (match, $0) {
            if (!is1P) {
                return '<em>【' + $0 + '】</em>'
            } else {
                return '<em class="green">【' + $0 + '】</em>'
            }
        }) + '<div style="color: #ccc; line-height: 10px;">-----------------</div>';
    }

    return {
        log: log
    }
})());
